package ioperation;

import Book.Book;
import Book.BookShelf;

import java.util.Scanner;

public class ReturnOperation implements IOperation{
    public void work(BookShelf bookShelf){
        System.out.println("请输入你想要归还的图书的书名：");
        Scanner scanner=new Scanner(System.in);
        String name=scanner.nextLine();
        int count=bookShelf.getNum();
        for (int i = 0; i <count ; i++) {
            Book book=bookShelf.getBook(i);
            if(book.getName().equals(name)){
                System.out.println("已找到你将归还书籍！");
                //将Boolean状态改为false
                book.setBorrowed(false);
                System.out.println("已归还！");
                return;
            }
        }
        System.out.println("没有你要归还的书籍！");
    }
}
